package org.apache.hadoop.contrib.ftp;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Properties;

import org.apache.ftpserver.ConnectionConfig;

public class HDFSConnectionConf implements ConnectionConfig{
    
    private Properties prop;
    
    public HDFSConnectionConf(String file){
        prop=new Properties();
        try {
            prop.load(new FileInputStream(file));
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
    
    @Override
    public int getMaxLoginFailures() {
       return Integer.parseInt(prop.getProperty("max-login-failures", "0"));
    }

    @Override
    public int getLoginFailureDelay() {
        return Integer.parseInt(prop.getProperty("login-failure-delay", "0"));
    }

    @Override
    public int getMaxAnonymousLogins() {
        return Integer.parseInt(prop.getProperty("max-anon-login", "0"));
    }

    @Override
    public int getMaxLogins() {
        return Integer.parseInt(prop.getProperty("max-logins", "0"));
    }

    @Override
    public boolean isAnonymousLoginEnabled() {
        return Boolean.parseBoolean(prop.getProperty("anon-enabled", "false"));
    }

}
